package com.boc.langxiang.ui.activity.me;

import android.os.Build;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;

import com.boc.langxiang.R;
import com.boc.langxiang.contract.me.AllOrdersActivityContract;
import com.boc.langxiang.presenter.me.OrdersAllActivityPresenter;
import com.boc.langxiang.ui.activity.BaseToolBarActivity;
import com.boc.langxiang.ui.adapter.me.OrdersAllPagerAdapter;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 订单列表
 */
public class OrdersActivity extends BaseToolBarActivity implements AllOrdersActivityContract.View {


    @BindView(R.id.tablayout_me_all_orders)
    TabLayout tablayoutMeAllOrders;
    @BindView(R.id.vp_me_all_orders)
    ViewPager vpMeAllOrders;
    private OrdersAllActivityPresenter mPresenter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_me_orders);
        ButterKnife.bind(this);
        setToolBarTitle("订单列表");
        initViewPresenter();
    }

    private void initViewPresenter() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
            tablayoutMeAllOrders.setLayoutMode(TabLayout.MODE_FIXED);
        }
        mPresenter = new OrdersAllActivityPresenter(this);
        mPresenter.initFragmentList();
        mPresenter.initAdapter(getSupportFragmentManager());
    }

    @Override
    protected boolean isSetTypeFace() {
        return true;
    }

    @Override
    public void setAdapter(OrdersAllPagerAdapter adapter) {
        vpMeAllOrders.setAdapter(adapter);
        tablayoutMeAllOrders.setupWithViewPager(vpMeAllOrders);
    }

    @Override
    public void showLoading() {

    }

    @Override
    public void hideLoading() {

    }

    @Override
    public void onError(String code, String msg) {

    }
}
